{% extends 'layout.html' %}

{% block title %}{{title}}{% endblock %}

{% block content %}
<div class="hbox hbox-auto-xs hbox-auto-sm">
    <!-- right col -->
    <div class="col w bg-light dker bg-auto">
        <div id="set-tab" class="list-group no-radius no-border no-bg m-t-n-xxs m-b-none auto">
            <a href="javascript:;" class="list-group-item">
                <h4>操作中心</h4>
            </a>
            {% if role > 1%}
                <a class="list-group-item active">
                    基本设置
                </a>
            {%endif%}
            {% if role > 2%}
            <a class="list-group-item">
                用户管理
            </a>
            {%endif%}
            {% if role > 1%}
                <a class="list-group-item">
                    分类管理
                </a>
            {% endif %}
            <a class="list-group-item {% if role <= 1%}active{%endif%}">
                文章管理
            </a>
        </div>
    </div>
    <!-- / right col -->
    <!-- main -->
    <div class="set-content col wrapper-lg">
        <div></div>


        {% if role > 1%}
        <!-- 基本设置 -->
        <div id="base-set" class="panel panel-default fade-in-up ng-enter">
            <div class="panel-heading font-bold">
                基本设置
            </div>
            <div class="panel-body">
                <form class="form-horizontal" method="get">

                    <!-- 网站描述 -->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">网站描述</label>

                        <div class="col-sm-10">
                            <input type="text" v-model="description" class="form-control" value="{{settings.description}}" placeholder="网站描述">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>

                    <!-- 网站关键字 -->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">网站关键字</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" v-model="keywords" value="{{settings.keywords}}" placeholder="网站关键字">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>

                    <!-- 帮助链接 -->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">帮助链接</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" v-model="helplink" value="{{settings.helpLink}}" placeholder="帮助链接">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>


                    <!-- 流量统计代码-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">流量统计代码</label>

                        <div class="col-sm-10">
                            <textarea style="resize:none;" v-model="statistics" class="form-control" rows="3" placeholder="流量统计代码">{{settings.statistics}}</textarea>
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>

                    <!-- save -->
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button type="submit" v-on="click:save" class="btn btn-primary">保存设置</button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
        {% endif %}

        <!-- 用户管理 -->
        {% if role > 2%}
        <div id="set-user" class="panel panel-default {% if role > 2%}hide{%endif%} fade-in-up ng-enter">

            <div class="form-inline">
                <div class="panel-body">

                    <div class="form-group">
                        <label class="sr-only">Email address</label>
                        <input type="text" class="form-control" v-model="search" placeholder="用户名/Email">
                    </div>
                    <button class="btn btn-sm btn-success" v-on="click:userList('search', 1)">搜索</button>

                    <span class="form-group m-l">
                            <a href="javascript:;" v-on="click:userList('all', 1)">全部</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="javascript:;" v-on="click:userList('admin', 1)">管理员</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="javascript:;" v-on="click:userList('developer', 1)">开发者</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="javascript:;" v-on="click:userList('member', 1)">会员</a>
                    </span>

                </div>
            </div>


            <div class="panel-heading font-bold">
                <%extra.title%>
                <span class="badge bg-warning pull-right"><%extra.total%></span>
            </div>


            <table class="table table-bordered table-hover table-condensed bg-white-only">
                <tr style="font-weight: bold">
                    <td style="width:15%">Email</td>
                    <td style="width:15%">昵称/个性后缀</td>
                    <td style="width:15%">积分</td>
                    <td style="width:10%">身份</td>
                    <td style="width:15%">注册时间</td>
                    <td style="width:15%">操作</td>
                </tr>



                <tr v-if="!users.length">
                    <td colspan="7" align="center">无数据</td>
                </tr>
                <!-- ngRepeat: user in users -->
                <tr v-repeat="user:users">

                    <!-- Email -->
                    <td class="v-middle">
                        <a class="text-ellipsis disabled"  target="_blank"><%user.email%></a>
                    </td>

                    <!-- 昵称 -->
                    <td class="v-middle">
                        <a class="disabled"><%user.nickname%></a>
                    </td>

                    <!--积分-->
                    <td class="v-middle">
                        <a href="javascript:;"><%user.level || 0%></a>
                    </td>

                    <!--身份-->
                    <td class="v-middle">
                        <a v-if="0==user.role" href="javascript:;">会员</a>
                        <a v-if="1==user.role" href="javascript:;">开发者</a>
                        <a v-if="2==user.role" href="javascript:;">管理员</a>
                    </td>

                    <!--注册时间-->
                    <td class="v-middle">
                        <a href="javascript:;"><%user.createtime%></a>
                    </td>

                    <!-- 操作-->
                    <td style="white-space: nowrap">
                        <div class="buttons">
                            <a href="/userEdit/<%user._id%>" target="_blank" class="btn btn-sm btn-info">编辑</a>
                            <button v-on="click:delUser" data-id="<%user._id%>" class="btn btn-sm btn-danger">删除</button>
                        </div>
                    </td>

                </tr>

            </table>

            <div class="loader wrapper text-center"><img src="/img/flickr.svg"/></div>
            <div v-if="extra.total/10>page" class="clearfix text-center panel-heading font-bold">
                <a href="javascript:;" class="auto" v-on="click:userList()">
                    <i class="fa fa-angle-double-down"></i>
                    <span>更多主题</span>
                </a>
            </div>

        </div>
        {% endif %}


        <!-- 分类-->
        {% if role > 1%}
        <div id="set-category" class="panel panel-default hide fade-in-up ng-enter">

            <div class="form-inline">
                <div class="panel-body">


                    <div class="form-group">
                        <input type="email" class="form-control" v-model="categoryName" placeholder="分类名称">
                    </div>
                    <button class="btn btn-sm btn-success" v-on="click:addCategory">添加分类</button>

                </div>
            </div>


            <div class="panel-heading font-bold">
                分类
            </div>


            <table  class="table table-bordered table-hover table-condensed bg-white-only">
                <tr id="category-tr" style="font-weight: bold">
                    <td style="width:35%">名称</td>
                    <td style="width:15%">操作</td>
                </tr>


                <!-- ngRepeat: user in users -->
                <tr v-repeat="category:categories">

                    <!-- 分类名 -->
                    <td class="v-middle">
                        <a href=""><%category.name%></a>
                    </td>

                    <!-- 操作-->
                    <td style="white-space: nowrap">
                        <div class="buttons">
                            <button class="btn btn-sm btn-danger" v-on="click:removeCategory($event, category.name)">删除</button>
                        </div>
                    </td>

                </tr>




            </table>


        </div>
        {% endif %}

        <!-- 文章 -->
        <div id="set-post" class="panel panel-default {% if role > 1%}hide{%endif%} fade-in-up ng-enter">

            <div class="form-inline">
                <div class="panel-body">


                        <div class="form-group">
                            <label class="sr-only">Email address</label>
                            <input type="text" class="form-control" v-model="search" placeholder="文章标题">
                        </div>
                          <button class="btn btn-sm btn-success" v-on="click:loadmore('search', 1)">搜索</button>

                    <span class="form-group m-l">
                            <a href="javascript:;" v-on="click:loadmore('all', 1)">全部</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="javascript:;" v-on="click:loadmore('already', 1)">已发布</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="javascript:;" v-on="click:loadmore('top', 1)">置顶</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="javascript:;" v-on="click:loadmore('draft', 1)">草稿</a>&nbsp;&nbsp;| &nbsp;&nbsp;<a href="javascript:;" v-on="click:loadmore('recommend', 1)">推荐</a>
                    </span>

                </div>
            </div>


            <div v-cloak class="panel-heading font-bold">
                <%extra.title%>
                <span class="badge bg-warning pull-right"><%extra.total%></span>
            </div>


            <table class="table table-bordered table-hover table-condensed bg-white-only">
                <tr style="font-weight: bold">
                    <td style="width:35%">标题</td>
                    <td style="width:12%">作者</td>
                    <td style="width:12%">分类目录</td>
                    <td style="width:7%">评论</td>
                    <td style="width:8%">状态</td>
                    <td style="width:10%">日期</td>
                    <td style="width:15%">操作</td>
                </tr>



                <tr v-cloak v-if="!posts.length">
                    <td colspan="7" align="center">无数据</td>
                </tr>
                <!-- ngRepeat: user in users -->
                <tr v-cloak v-repeat="post:posts">

                    <!-- 标题 -->
                    <td class="v-middle">
                        <a class="text-ellipsis" href="/<%post.type%>/<%post._id%>" target="_blank"><%post.title%></a>
                    </td>

                    <!-- 作者 -->
                    <td class="v-middle">
                        <a href="/user/<%post.name%>"><%post.name%></a>
                    </td>

                    <!--分类-->
                    <td class="v-middle">
                        <a href="javascript:;"><%post.category%></a>
                    </td>

                    <!--评论count-->
                    <td class="v-middle">
                        <a href="/<%post.type%>/<%post._id%>"><%post.commentCount%></a>
                    </td>

                    <!--状态-->
                    <td class="v-middle">
                        <a href="javascript:;" v-if="post.status">已发布</a>
                        <a href="javascript:;" v-if="!post.status">草稿</a>
                    </td>


                    <!--日期-->
                    <td class="v-middle">
                        <a href="javascript:;" title="<%post.createtime%>"><%post.createtimeformat%></a>
                    </td>

                    <!-- 操作-->
                    <td style="white-space: nowrap">
                        <div class="buttons">
                            <a href="/<%post.type%>/<%post._id%>/edit" target="_blank" class="btn btn-sm btn-info">编辑</a>
                            <button id="#post-del" v-on="click:del" data-id="<%post._id%>" class="btn btn-sm btn-danger">删除</button>
                        </div>
                    </td>

                </tr>




            </table>
            <div class="loader wrapper text-center"><img src="/img/flickr.svg"/></div>
            <div v-cloak v-if="extra.total/10>page" class="clearfix text-center panel-heading font-bold">
                <a href="javascript:;" class="auto" v-on="click:loadmore()">
                    <i class="fa fa-angle-double-down"></i>
                    <span>更多主题</span>
                </a>
            </div>

        </div>


    </div>
    <!-- / main -->
</div>

{% endblock %}
{% block loadjs %}
<script>
    require(['user/settings.min']);
</script>
{% endblock %}
